package com.swordliu.facebook.service.impl;

import com.swordliu.facebook.Utils.SecureUtils;
import com.swordliu.facebook.dao.UserMapper;
import com.swordliu.facebook.dao.base.BaseMapper;
import com.swordliu.facebook.pojo.entity.User;
import com.swordliu.facebook.service.UserService;
import com.swordliu.facebook.service.base.BaseServiceSupport;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.DefaultHashService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * userServiceImpl
 * Created by SwordLiu on 2017-07-03.
 */
@Service
public class UserServiceImpl extends BaseServiceSupport<User> implements UserService {

    public final static String SALT_SEED = "123";

    @Resource
    private UserMapper userMapper;

    @Override
    public User getUser(String username) throws Exception {
        return userMapper.selectUserByUsernameAndPassword(username);
    }

    @Override
    public Integer regist(User regist) throws Exception {
        User user = SecureUtils.encryptionPassword(regist);
        return userMapper.insertSelective(user);
    }

    @Override
    public List<User> getUsers() throws Exception {
        return userMapper.selectUsers();
    }

    @Override
    protected BaseMapper<User> getBaseMapper() {
        return userMapper;
    }
}
